import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0
import "base"

Window {
    id: dialogRoot
    visible: true
    width: 400
    height: 520
    title: "点云配准参数设置"
    modality: Qt.ApplicationModal
    flags: (Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint | Qt.Window)
    color: Common.colorTransParent
    DropShadow {
        id: rectShadow
        anchors.fill: mainView
        cached: true
        radius: parent.height / 80
        samples: 16
        color: "black"
        source: mainView
    }

    Rectangle {
        id: mainView
        anchors.fill: parent
        anchors.margins: 10
        radius: 4

        Rectangle {
            id: title
            color: Common.colorBG
            height: 40
            width: parent.width
            anchors.top: parent.top
            property int originX: 0
            property int originY: 0

            Text {
                id: titleText
                font.family: Common.fontMain
                color: Common.colorMain
                anchors.left: parent.left
                anchors.leftMargin: 10
                font.pixelSize: 18
                anchors.verticalCenter: parent.verticalCenter
                text: "点云配准参数设置"
            }
            MouseArea {
                anchors.fill: parent
                acceptedButtons: Qt.LeftButton
                onPressed: {
                    title.originX = mouseX
                    title.originY = mouseY
                }
                onPositionChanged: {
                    dialogRoot.x = dialogRoot.x + mouseX - title.originX
                    dialogRoot.y = dialogRoot.y + mouseY - title.originY
                }
            }

            Item {
                anchors.right: parent.right
                anchors.top: parent.top
                height: parent.height
                width: height
                Image {
                    id: iconImage
                    source: "qrc:/resource/icon_close.svg"
                    anchors.centerIn: parent
                    sourceSize.height: parent.height * 0.7
                    antialiasing: true
                }
                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
                    onExited: parent.scale = 1
                    onEntered: parent.scale = 0.8
                    onClicked: {
                        dialogRoot.close()
                    }
                }
            }
        }

        Column {
            anchors.top: title.bottom
            anchors.left: parent.left
            anchors.margins: 20
            spacing: 10
            Row {
                spacing: 10
                Text {
                    text: "体素大小: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "最大点对距离: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "法向搜索邻域: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "欧氏距离收敛阈值: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "FPFH邻域: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "变换矩阵收敛域值: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "粗配准最大迭代次数: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
            Row {
                spacing: 10
                Text {
                    text: "精配准最大迭代次数: "
                    font.family: Common.fontMain
                    color: Common.colorMain
                    font.pixelSize: 14
                    width: 150
                    anchors.verticalCenter: parent.verticalCenter
                }
                MyTextInput {
                    width: 150
                    height: 35
                }
            }
        }
        Row {
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.margins: 20
            spacing: 10
            MyButton {
                height: 35
                width: 100
                text: "保存参数"
            }
            MyButton {
                height: 35
                width: 100
                text: "退出不保存"
            }
        }
    }
}
